home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Gallery / Source / ThumbnailWindow.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-15  |  2.2 KB  |  102 lines

  1. #include <stream.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <stdio.h>
  6.  
  7. #include "GUICINCLUDE:GUIC_Screen.hpp"
  8. #include "GUICINCLUDE:GUIC_Application.hpp"
  9. #include "GUICINCLUDE:GUIC_GGFXPicture.hpp"
  10. #include "GUICINCLUDE:GUIC_Text.hpp"
  11. #include "GUICINCLUDE:GUIC_Exceptions.hpp"
  12.  
  13. #include "ThumbnailWindow.hpp"
  14.  
  15. /*********************************************************************************************************/
  16.  
  17. ThumbnailWindowC::ThumbnailWindowC                     (GUIC_ApplicationC &app, GUIC_ScreenC &screen) : GUIC_WindowC (-1,-1,10,10)
  18. {
  19.     this->app             = &app;
  20.     this->screen        = &screen;
  21.     this->thumbnail    = 0;
  22.     this->width            = 100;
  23.     this->height        = 100;
  24.     
  25.     textGadget            = 0;
  26.     
  27.     setCloseGadgetMode ( FALSE );
  28.     setZoomMode ( FALSE );
  29.     
  30.     setGuideContext("ThumbnailWindow");
  31.     app.addPrefs("ThumbnailWindow",    this);
  32.  
  33.     setTitle ( "Thumbnail" );
  34. }
  35. ThumbnailWindowC::~ThumbnailWindowC                     (VOID)
  36. {
  37.     cleanUp();
  38. }
  39.  
  40. /*********************************************************************************************************/
  41.  
  42. VOID        ThumbnailWindowC::setTextGadget            (GUIC_TextC *t)
  43. {
  44.     textGadget = t;
  45. }
  46. BOOL        ThumbnailWindowC::loaded                            (VOID)
  47. {
  48.     return (thumbnail != 0);
  49. }
  50.  
  51. VOID        ThumbnailWindowC::setDimensions            (LONG x, LONG y)
  52. {
  53.     width = x;
  54.     height = y;
  55.     
  56.     setPixelWidth (x);
  57.     setPixelHeight (y);
  58. }
  59. VOID        ThumbnailWindowC::showThumbnail            (STRPTR fileName)
  60. {
  61.     if (thumbnail) 
  62.         {
  63.         remove (thumbnail);
  64.         delete thumbnail; thumbnail=0;
  65.         }
  66.     
  67.     if (strcmp(fileName, "")) // then there is no thumbnail to show
  68.         {
  69.         try
  70.             {
  71.             if (textGadget) textGadget->set("Loading thumbnail ...");
  72.             thumbnail = new GUIC_GGFXPictureC (fileName);
  73.         
  74.             if (textGadget) textGadget->set("Showing thumbnail." );
  75.             thumbnail->setCentered(TRUE);
  76.             add (thumbnail);
  77.             }
  78.         catch (GUIC_Exception &e)
  79.             {
  80.             if (thumbnail) { remove(thumbnail); delete thumbnail; thumbnail = 0; }
  81.             if (textGadget) textGadget->set( "Could not load thumbnail.");
  82.             }
  83.         }
  84. }
  85.  
  86. STRPTR    ThumbnailWindowC::getClass                        (VOID)
  87. {
  88.     return "ThumbnailWindowC";
  89. }
  90.  
  91. /*********************************************************************************************************/
  92.  
  93. VOID         ThumbnailWindowC::cleanUp                        (VOID)
  94. {    
  95.     if (thumbnail)
  96.         {
  97.         remove (thumbnail);
  98.         delete thumbnail;
  99.         }
  100. }
  101.  
  102.